//package com.yuanlun.elasticsearch.controller;
//
//import com.yuanlun.elasticsearch.entity.Movies;
//import com.yuanlun.elasticsearch.repository.MoviesRespository;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.data.domain.Pageable;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.time.Year;
//import java.util.Arrays;
//import java.util.List;
//
//
///**
// * @ClassName MoviesController
// * @Description TODO
// * @Author zxw
// * @DATE 2021/4/30 11:11
// * Version 1.0
// **/
//@RestController
//@RequestMapping("/movies")
//public class MoviesController {
//    private MoviesRespository  moviesRespository;
//
//    public MoviesController(MoviesRespository moviesRespository) {
//        this.moviesRespository = moviesRespository;
//    }
//
//    @GetMapping(value = "/getPageData")
//    public List<Movies> getPageData(@RequestParam String title,
//                                    @RequestParam(defaultValue = "1") Integer page,
//                                    @RequestParam(defaultValue = "10") Integer size){
//        Pageable pageable = PageRequest.of(page, size);
////        Page<Movies> pageData = moviesRespository.findByTitle(title, pageable);
////
////        return pageData.getContent();
//        return moviesRespository.findByTitle(title);
//    }
//
//    @GetMapping(value = "/multiFieldsQuery")
//    public List<Movies> multiFieldsQuery(String title,String genre,
//                                         @RequestParam(defaultValue = "1")Integer page,
//                                         @RequestParam(defaultValue = "10") Integer size){
//        Pageable pageable = PageRequest.of(page, size);
//        Page<Movies> pageData = moviesRespository.findByTitleAndGenre(title, genre,pageable);
//        return pageData.getContent();
//    }
//
//    @GetMapping(value = "/inQuery")
//    public List<Movies> inQuery(String[] titles,
//                                         @RequestParam(defaultValue = "1")Integer page,
//                                         @RequestParam(defaultValue = "10") Integer size){
//        Pageable pageable = PageRequest.of(page, size);
//        Page<Movies> pageData = moviesRespository.findByTitleIn(Arrays.asList(titles),pageable);
//        return pageData.getContent();
//    }
//
//    @GetMapping(value = "/betweenQuery")
//    public List<Movies> betweenQuery(String title,Integer begin,Integer end,
//                                @RequestParam(defaultValue = "1")Integer page,
//                                @RequestParam(defaultValue = "10") Integer size){
//        Pageable pageable = PageRequest.of(page, size);
//        Page<Movies> pageData = moviesRespository.findByTitleAndYearBetween(title, begin,end,pageable);
//        return pageData.getContent();
//    }
//
//    @GetMapping(value = "/selfQuery")
//    public List<Movies> selfQuery(String title,String genre){
//        return moviesRespository.get(title, genre);
//    }
//}
